#include <my_header.h>

void * threadFunc(void * arg)
{
    printf("I am child thread.\n");

    int *fd = (int *)arg;
    char buf[60] = {0};
    int read_num = read(*fd,buf,sizeof(buf));
    write(STDOUT_FILENO,buf,read_num);
    return NULL;
}

/* usage */
int main(int argc, char *argv[])
{
    ARGS_CHECK(argc,1);

    int fd = open("1.txt",O_RDONLY);

    pthread_t tid;
    int ret = pthread_create(&tid,NULL,threadFunc,&fd);
    ERROR_CHECK(ret,-1,"pthread_create");

    printf("I am main thread.\n");
    pthread_join(tid,NULL);
    return 0;
}

